﻿<phone:PhoneApplicationPage x:Class="CetWin.Views.MainPage" x:Name="mainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    xmlns:views="clr-namespace:CetWin.Views"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:cw="clr-namespace:CetWin.Phone.Controls;assembly=CetWin.Phone"
    xmlns:phoneControl="clr-namespace:Phone.Framework.Controls;assembly=Phone.Framework"
    xmlns:phoneExt="clr-namespace:Phone.Framework.Behaviors;assembly=Phone.Framework"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:c4f="clr-namespace:Coding4Fun.Phone.Controls;assembly=Coding4Fun.Phone.Controls"
    xmlns:cal="clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro"
    xmlns:ce="clr-namespace:Phone.Framework.CaliburnExtensions"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="696"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait"  Orientation="Portrait"
    toolkit:TiltEffect.IsTiltEnabled="True"
    phoneExt:PageBehavior.ExitPrompt="{Binding ShowWarnWhenExit}"
    shell:SystemTray.IsVisible="True">
    <phone:PhoneApplicationPage.Resources>
        
    </phone:PhoneApplicationPage.Resources>
        <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <TextBlock Margin="24,0,0,0" x:Name="ApplicationTitle" Text="CetWin" Style="{StaticResource PhoneTextNormalStyle}"/>
        <!--<StackPanel Orientation="Horizontal" HorizontalAlignment="Right"  ce:CabiburnService.TypeWithDataContext="CetWin.ViewModels.WordStatistics">
            <TextBlock Text="{Binding TotalCount,StringFormat=共\{0\}}"/>
            <TextBlock Text="{Binding Cet4LibraryWordCount,StringFormat=CET4共\{0\}}"/>
            <TextBlock Text="{Binding Cet6LibraryWordCount,StringFormat=CET6共\{0\}}" />
        </StackPanel>-->
       
        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="1" Margin="12,17,0,12">
            
            <toolkit:ListPicker Header="Word Libraries" Visibility="Collapsed"
                                SelectionMode="Multiple" SelectedItem="{Binding SelectedWordLibrary}"
                                FullModeHeader="Word Libraries"
                                cal:Message.Attach="[Event SelectionChanged] = [Action SelectWordLibrary($source)]"
                                x:Name="wordLibraries_Element">
                <!--<i:Interaction.Triggers>
                    <i:EventTrigger EventName="SelectionChanged">
                        <i:InvokeCommandAction Command="{Binding SelectWLCommand}" />
                    </i:EventTrigger>
                </i:Interaction.Triggers>-->
                <sys:String>CET4</sys:String>
                <sys:String>CET6</sys:String>
            </toolkit:ListPicker>

            <StackPanel Orientation="Horizontal" Margin="0,0,24,0">

                <!--<phoneControl:RoundButton HorizontalAlignment="Center" VerticalAlignment="Center"
                                 ImageSource="/Resources/Icons/appbar.favs.addto.rest.png" />-->
               
                <toolkit:PhoneTextBox Hint="Search" Width="450"
                                      x:Name="searchBox"
                                      Text="{Binding SearchText,Mode=TwoWay}"
                                      ActionIcon="/Images/Search.png"
                                      cal:Message.Attach="[Event ActionIconTapped] = [Action SearchNetworkWord()];
                                      [Event KeyUp] = [Action OnSearchKeyUp($eventargs)]">
                    <i:Interaction.Behaviors>
                        <phoneExt:UpdateTextBindingOnPropertyChanged />
                        <phoneExt:UpdateSelectedValueOnPropertyChanged 
                            SelectedValue="{Binding SelectedValue,Mode=TwoWay}" 
                            Selector="{Binding ElementName=words_Element}" />
                    </i:Interaction.Behaviors>
                </toolkit:PhoneTextBox>
                <!--<views:AlphaSelector SelectedAlpha="{Binding Text,ElementName=searchBox,Mode=TwoWay}" />-->
            </StackPanel>

        </StackPanel>
            <Grid Grid.Row="2" Margin="12, 0">
            <ListBox SelectedItem="{Binding SelectedWord,Mode=TwoWay}"
                     
                     x:Name="words_Element"
                     SelectedValuePath="Name"
                     SelectedValue="{Binding SelectedValue}"
                     ItemTemplate="{Binding ItemTemplate,Converter={StaticResource ResourceConverter},Mode=TwoWay}"
                     Margin="12,0,12,0"
                     ItemsSource="{Binding SearchResult}">
                <i:Interaction.Behaviors>
                    <phoneExt:NoItemsSourceTipBehavior />
                    
                </i:Interaction.Behaviors>
                </ListBox>
            </Grid>
    </Grid>
    <!--Sample code showing usage of ApplicationBar-->
    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBar.Buttons>
                <!--<cal:AppBarButton IconUri="Resources/Icons/appbar.favs.addto.rest.png"
                                  Text="Favorite"
                                  Message="AddToHistory" />-->
                <!--<cal:AppBarButton IconUri="Resources/Icons/appbar.feature.search.rest.png"
                                  Text="Search"
                                  Message="SearchDetail" />-->
                <cal:AppBarButton IconUri="Resources/Icons/appbar.favs.rest.png"
                                  Text="Favorite"
                                  Message="OpenHistoryView" />
                <cal:AppBarButton IconUri="Resources/Icons/appbar.feature.settings.rest.png"
                                  Text="Settings"
                                  Message="OpenSettingsView" />
                <cal:AppBarButton IconUri="Resources/Icons/appbar.questionmark.rest.png"
                                  Text="About"
                                  Message="OpenAboutView" />
            </shell:ApplicationBar.Buttons>
           
            <shell:ApplicationBar.MenuItems>
                <!--<cal:AppBarMenuItem Text="Select Word Libraries"
                                    Message="Open" />-->
                <!--<shell:ApplicationBarMenuItem Text="Select Word Libraries"/>-->
                <!--<shell:ApplicationBarMenuItem Text="Select WordTemplate"/>-->
                <cal:AppBarMenuItem Text="Category"
                                    Message="OpenCategoryView" />
                <!--<cal:AppBarMenuItem Text="About"
                                    Message="OpenAboutView" />-->
                <!--<cal:AppBarMenuItem Text="Log"
                                    Message="OpenLogView" />-->
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>
    <i:Interaction.Behaviors>
        <!--<phoneExt:ApplicationBarAction ApplicationBarType="MenuItem" ButtonText="Select Word Libraries"
                                       TargetObjectName="wordLibraries_Element" MethodName="Open">
        </phoneExt:ApplicationBarAction>-->
        <!--<phoneExt:ApplicationBarButtonIconSwitchBehavior Text="Favorite"
                                                         IconUri="Resources/Icons/appbar.favs.remove.rest.png"
                                                         CanSwitch="{Binding CanSwitchHistoryIcon,Mode=TwoWay}" />-->
        <phoneExt:MediaPlayBehavior />
    </i:Interaction.Behaviors>
</phone:PhoneApplicationPage>